package org.concept.chinachesspieces.core;

public class BlackStep {
	public static int[] stepGun(byte[][] qj, int i, int j) {
		int[] step = new int[17];
		int action = 0;
		int count = 0;
		byte over = 0;
		int checkFlag = 0;
		int nocheck = step.length - 1;
		int flag = 0;
		for (int x = i - 1; x >= 0; x--) {
			if (flag == 0) {
				if (qj[x][j] == Constants.EMPTY) {
					action = i * 1000 + j * 100 + x * 10 + j;
					over = qj[x][j];
					qj[x][j] = Constants.BLACK_GUN;
					qj[i][j] = Constants.EMPTY;
					if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
						count++;
						if (Check.checkRed(qj)) {
							step[checkFlag++] = action;
						} else {
							step[nocheck--] = action;
						}
					}
					qj[i][j] = Constants.BLACK_GUN;
					qj[x][j] = over;
				} else {
					flag = 1;
				}
			} else {
				if (qj[x][j] != Constants.EMPTY) {
					if (qj[x][j] >= Constants.RED_CAR
							&& qj[x][j] <= Constants.RED_SOLDIER) {
						action = i * 1000 + j * 100 + x * 10 + j;
						over = qj[x][j];
						qj[x][j] = Constants.BLACK_GUN;
						qj[i][j] = Constants.EMPTY;
						if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
							count++;
							if (Check.checkRed(qj)) {
								step[checkFlag++] = action;
							} else {
								step[nocheck--] = action;
							}
						}
						qj[i][j] = Constants.BLACK_GUN;
						qj[x][j] = over;
					}
					break;
				}
			}
		}
		flag = 0;
		for (int x = i + 1; x <= 9; x++) {
			if (flag == 0) {
				if (qj[x][j] == Constants.EMPTY) {
					action = i * 1000 + j * 100 + x * 10 + j;
					over = qj[x][j];
					qj[x][j] = Constants.BLACK_GUN;
					qj[i][j] = Constants.EMPTY;
					if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
						count++;
						if (Check.checkRed(qj)) {
							step[checkFlag++] = action;
						} else {
							step[nocheck--] = action;
						}
					}
					qj[i][j] = Constants.BLACK_GUN;
					qj[x][j] = over;
				} else {
					flag = 1;
				}
			} else {
				if (qj[x][j] != Constants.EMPTY) {
					if (qj[x][j] >= Constants.RED_CAR
							&& qj[x][j] <= Constants.RED_SOLDIER) {
						action = i * 1000 + j * 100 + x * 10 + j;
						over = qj[x][j];
						qj[x][j] = Constants.BLACK_GUN;
						qj[i][j] = Constants.EMPTY;
						if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
							count++;
							if (Check.checkRed(qj)) {
								step[checkFlag++] = action;
							} else {
								step[nocheck--] = action;
							}
						}
						qj[i][j] = Constants.BLACK_GUN;
						qj[x][j] = over;
					}
					break;
				}
			}
		}
		flag = 0;
		for (int y = j - 1; y >= 0; y--) {
			if (flag == 0) {
				if (qj[i][y] == Constants.EMPTY) {
					action = i * 1000 + j * 100 + i * 10 + y;
					over = qj[i][y];
					qj[i][y] = Constants.BLACK_GUN;
					qj[i][j] = Constants.EMPTY;
					if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
						count++;
						if (Check.checkRed(qj)) {
							step[checkFlag++] = action;
						} else {
							step[nocheck--] = action;
						}
					}
					qj[i][j] = Constants.BLACK_GUN;
					qj[i][y] = over;
				} else {
					flag = 1;
				}
			} else {
				if (qj[i][y] != Constants.EMPTY) {
					if (qj[i][y] >= Constants.RED_CAR
							&& qj[i][y] <= Constants.RED_SOLDIER) {
						action = i * 1000 + j * 100 + i * 10 + y;
						over = qj[i][y];
						qj[i][y] = Constants.BLACK_GUN;
						qj[i][j] = Constants.EMPTY;
						if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
							count++;
							if (Check.checkRed(qj)) {
								step[checkFlag++] = action;
							} else {
								step[nocheck--] = action;
							}
						}
						qj[i][j] = Constants.BLACK_GUN;
						qj[i][y] = over;
					}
					break;
				}
			}
		}
		flag = 0;
		for (int y = j + 1; y <= 8; y++) {
			if (flag == 0) {
				if (qj[i][y] == Constants.EMPTY) {
					action = i * 1000 + j * 100 + i * 10 + y;
					over = qj[i][y];
					qj[i][y] = Constants.BLACK_GUN;
					qj[i][j] = Constants.EMPTY;
					if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
						count++;
						if (Check.checkRed(qj)) {
							step[checkFlag++] = action;
						} else {
							step[nocheck--] = action;
						}
					}
					qj[i][j] = Constants.BLACK_GUN;
					qj[i][y] = over;
				} else {
					flag = 1;
				}
			} else {
				if (qj[i][y] != Constants.EMPTY) {
					if (qj[i][y] >= Constants.RED_CAR
							&& qj[i][y] <= Constants.RED_SOLDIER) {
						action = i * 1000 + j * 100 + i * 10 + y;
						over = qj[i][y];
						qj[i][y] = Constants.BLACK_GUN;
						qj[i][j] = Constants.EMPTY;
						if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
							count++;
							if (Check.checkRed(qj)) {
								step[checkFlag++] = action;
							} else {
								step[nocheck--] = action;
							}
						}
						qj[i][j] = Constants.BLACK_GUN;
						qj[i][y] = over;
					}
					break;
				}
			}
		}
		return step;
	}

	public static int[] stepCar(byte[][] qj, int i, int j) {
		int[] step = new int[17];
		int action = 0;
		int count = 0;
		byte over = 0;
		int checkFlag = 0;
		int nocheck = step.length - 1;
		for (int x = i - 1; x >= 0; x--) {
			if (qj[x][j] <= Constants.RED_SOLDIER) {
				action = i * 1000 + j * 100 + x * 10 + j;
				over = qj[x][j];
				qj[x][j] = Constants.BLACK_CAR;
				qj[i][j] = Constants.EMPTY;
				if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
					count++;
					if (Check.checkRed(qj)) {
						step[checkFlag++] = action;
					} else {
						step[nocheck--] = action;
					}
				}
				qj[i][j] = Constants.BLACK_CAR;
				qj[x][j] = over;

			}
			if (qj[x][j] != Constants.EMPTY) {
				break;
			}
		}
		for (int x = i + 1; x <= 9; x++) {
			if (qj[x][j] <= Constants.RED_SOLDIER) {
				action = i * 1000 + j * 100 + x * 10 + j;
				over = qj[x][j];
				qj[x][j] = Constants.BLACK_CAR;
				qj[i][j] = Constants.EMPTY;
				if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
					count++;
					if (Check.checkRed(qj)) {
						step[checkFlag++] = action;
					} else {
						step[nocheck--] = action;
					}
				}
				qj[i][j] = Constants.BLACK_CAR;
				qj[x][j] = over;
			}
			if (qj[x][j] != Constants.EMPTY) {
				break;
			}
		}
		for (int y = j - 1; y >= 0; y--) {
			if (qj[i][y] <= Constants.RED_SOLDIER) {
				action = i * 1000 + j * 100 + i * 10 + y;
				over = qj[i][y];
				qj[i][y] = Constants.BLACK_CAR;
				qj[i][j] = Constants.EMPTY;
				if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
					count++;
					if (Check.checkRed(qj)) {
						step[checkFlag++] = action;
					} else {
						step[nocheck--] = action;
					}
				}
				qj[i][j] = Constants.BLACK_CAR;
				qj[i][y] = over;
			}
			if (qj[i][y] != Constants.EMPTY) {
				break;
			}
		}
		for (int y = j + 1; y <= 8; y++) {
			if (qj[i][y] <= Constants.RED_SOLDIER) {
				action = i * 1000 + j * 100 + i * 10 + y;
				over = qj[i][y];
				qj[i][y] = Constants.BLACK_CAR;
				qj[i][j] = Constants.EMPTY;
				if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
					count++;
					if (Check.checkRed(qj)) {
						step[checkFlag++] = action;
					} else {
						step[nocheck--] = action;
					}
				}
				qj[i][j] = Constants.BLACK_CAR;
				qj[i][y] = over;
			}
			if (qj[i][y] != Constants.EMPTY) {
				break;
			}
		}
		return step;
	}

	public static int[] stepGuests(byte[][] qj, int i, int j) {
		int[] step = new int[4];
		int action = 0;
		int count = 0;
		byte over = 0;
		int checkFlag = 0;
		int nocheck = step.length - 1;
		if (i == 8 && j == 4) {
			if (qj[9][3] <= Constants.RED_SOLDIER) {
				action = 8493;
				over = qj[9][3];
				qj[i][j] = Constants.EMPTY;
				qj[9][3] = Constants.BLACK_GUESTS;
				if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
					count++;
					if (Check.checkRed(qj)) {
						step[checkFlag++] = action;
					} else {
						step[nocheck--] = action;
					}
				}
				qj[i][j] = Constants.BLACK_GUESTS;
				qj[9][3] = over;
			}
			if (qj[7][3] <= Constants.RED_SOLDIER) {
				action = 8473;
				over = qj[7][3];
				qj[i][j] = Constants.EMPTY;
				qj[7][3] = Constants.BLACK_GUESTS;
				if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
					count++;
					if (Check.checkRed(qj)) {
						step[checkFlag++] = action;
					} else {
						step[nocheck--] = action;
					}
				}
				qj[i][j] = Constants.BLACK_GUESTS;
				qj[7][3] = over;

			}
			if (qj[7][5] <= Constants.RED_SOLDIER) {
				action = 8475;
				over = qj[7][5];
				qj[i][j] = Constants.EMPTY;
				qj[7][5] = Constants.BLACK_GUESTS;
				if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
					count++;
					if (Check.checkRed(qj)) {
						step[checkFlag++] = action;
					} else {
						step[nocheck--] = action;
					}
				}
				qj[i][j] = Constants.BLACK_GUESTS;
				qj[7][5] = over;
			}
			if (qj[9][5] <= Constants.RED_SOLDIER) {
				action = 8495;
				over = qj[9][5];
				qj[i][j] = Constants.EMPTY;
				qj[9][5] = Constants.BLACK_GUESTS;
				if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
					count++;
					if (Check.checkRed(qj)) {
						step[checkFlag++] = action;
					} else {
						step[nocheck--] = action;
					}
				}
				qj[i][j] = Constants.BLACK_GUESTS;
				qj[9][5] = over;
			}
		} else if (qj[8][4] <= Constants.RED_SOLDIER) {
			action = i * 1000 + j * 100 + 84;
			over = qj[8][4];
			qj[8][4] = Constants.BLACK_GUESTS;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}

			}
			qj[i][j] = Constants.BLACK_GUESTS;
			qj[8][4] = over;
		} else {
			// do something
		}
		return step;
	}

	public static int[] stepMarshal(byte[][] qj, int i, int j) {
		int[] step = new int[4];
		int action = 0;
		int count = 0;
		byte over = 0;
		int checkFlag = 0;
		int nocheck = step.length - 1;
		if (i > 7 && (qj[i - 1][j] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i - 1) * 10 + j;
			over = qj[i - 1][j];
			qj[i - 1][j] = Constants.BLACK_MARSHAL;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_MARSHAL;
			qj[i - 1][j] = over;
		}
		if (i < 9 && (qj[i + 1][j] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i + 1) * 10 + j;
			over = qj[i + 1][j];
			qj[i + 1][j] = Constants.BLACK_MARSHAL;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_MARSHAL;
			qj[i + 1][j] = over;
		}

		if (j > 3 && (qj[i][j - 1] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + i * 10 + (j - 1);
			over = qj[i][j - 1];
			qj[i][j - 1] = Constants.BLACK_MARSHAL;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_MARSHAL;
			qj[i][j - 1] = over;
		}

		if (j < 5 && (qj[i][j + 1] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + i * 10 + (j + 1);
			over = qj[i][j + 1];
			qj[i][j + 1] = Constants.BLACK_MARSHAL;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_MARSHAL;
			qj[i][j + 1] = over;
		}
		return step;
	}

	public static int[] stepSoldier(byte[][] qj, int i, int j) {
		int[] step = new int[4];
		int action = 0;
		int count = 0;
		byte over = 0;
		int checkFlag = 0;
		int nocheck = step.length - 1;
		if (i >= 1 && (qj[i - 1][j] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i - 1) * 10 + j;
			over = qj[i - 1][j];
			qj[i - 1][j] = Constants.BLACK_SOLDIER;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_SOLDIER;
			qj[i - 1][j] = over;
		}
		if (i < 5 && j >= 1 && (qj[i][j - 1] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + i * 10 + (j - 1);
			over = qj[i][j - 1];
			qj[i][j - 1] = Constants.BLACK_SOLDIER;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_SOLDIER;
			qj[i][j - 1] = over;
		}
		if (i < 5 && j <= 7 && (qj[i][j + 1] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + i * 10 + (j + 1);
			over = qj[i][j + 1];
			qj[i][j + 1] = Constants.BLACK_SOLDIER;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_SOLDIER;
			qj[i][j + 1] = over;
		}
		return step;
	}

	public static int[] stepHorst(byte[][] qj, int i, int j) {
		int[] step = new int[8];
		int action = 0;
		int count = 0;
		byte over = 0;
		int checkFlag = 0;
		int nocheck = step.length - 1;
		if (i >= 2 && j >= 1 && qj[i - 1][j] == Constants.EMPTY
				&& (qj[i - 2][j - 1] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i - 2) * 10 + (j - 1);
			over = qj[i - 2][j - 1];
			qj[i - 2][j - 1] = Constants.BLACK_HORSE;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_HORSE;
			qj[i - 2][j - 1] = over;
		}
		if (i >= 1 && j >= 2 && qj[i][j - 1] == Constants.EMPTY
				&& (qj[i - 1][j - 2] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i - 1) * 10 + (j - 2);
			over = qj[i - 1][j - 2];
			qj[i - 1][j - 2] = Constants.BLACK_HORSE;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_HORSE;
			qj[i - 1][j - 2] = over;
		}
		if (i <= 8 && j >= 2 && qj[i][j - 1] == Constants.EMPTY
				&& (qj[i + 1][j - 2] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i + 1) * 10 + (j - 2);
			over = qj[i + 1][j - 2];
			qj[i + 1][j - 2] = Constants.BLACK_HORSE;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_HORSE;
			qj[i + 1][j - 2] = over;
		}
		if (i <= 7 && j >= 1 && qj[i + 1][j] == Constants.EMPTY
				&& (qj[i + 2][j - 1] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i + 2) * 10 + (j - 1);
			over = qj[i + 2][j - 1];
			qj[i + 2][j - 1] = Constants.BLACK_HORSE;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_HORSE;
			qj[i + 2][j - 1] = over;
		}
		if (i >= 2 && j <= 7 && qj[i - 1][j] == Constants.EMPTY
				&& (qj[i - 2][j + 1] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i - 2) * 10 + (j + 1);
			over = qj[i - 2][j + 1];
			qj[i - 2][j + 1] = Constants.BLACK_HORSE;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_HORSE;
			qj[i - 2][j + 1] = over;
		}
		if (i >= 1 && j <= 6 && qj[i][j + 1] == Constants.EMPTY
				&& (qj[i - 1][j + 2] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i - 1) * 10 + (j + 2);
			over = qj[i - 1][j + 2];
			qj[i - 1][j + 2] = Constants.BLACK_HORSE;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_HORSE;
			qj[i - 1][j + 2] = over;
		}
		if (i <= 8 && j <= 6 && qj[i][j + 1] == Constants.EMPTY
				&& (qj[i + 1][j + 2] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i + 1) * 10 + (j + 2);
			over = qj[i + 1][j + 2];
			qj[i + 1][j + 2] = Constants.BLACK_HORSE;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_HORSE;
			qj[i + 1][j + 2] = over;
		}
		if (i <= 7 && j <= 7 && qj[i + 1][j] == Constants.EMPTY
				&& (qj[i + 2][j + 1] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i + 2) * 10 + (j + 1);
			over = qj[i + 2][j + 1];
			qj[i + 2][j + 1] = Constants.BLACK_HORSE;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_HORSE;
			qj[i + 2][j + 1] = over;
		}
		return step;
	}

	public static int[] stepElephont(byte[][] qj, int i, int j) {
		int[] step = new int[4];
		int action = 0;
		int count = 0;
		byte over = 0;
		int checkFlag = 0;
		int nocheck = step.length - 1;
		if (i >= 7 && j >= 2 && qj[i - 1][j - 1] == Constants.EMPTY
				&& (qj[i - 2][j - 2] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i - 2) * 10 + (j - 2);
			over = qj[i - 2][j - 2];
			qj[i - 2][j - 2] = Constants.BLACK_ELEPHONT;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_ELEPHONT;
			qj[i - 2][j - 2] = over;
		}
		if (i <= 7 && j >= 2 && qj[i + 1][j - 1] == Constants.EMPTY
				&& (qj[i + 2][j - 2] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i + 2) * 10 + (j - 2);
			over = qj[i + 2][j - 2];
			qj[i + 2][j - 2] = Constants.BLACK_ELEPHONT;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_ELEPHONT;
			qj[i + 2][j - 2] = over;
		}
		if (i >= 7 && j <= 6 && qj[i - 1][j + 1] == Constants.EMPTY
				&& (qj[i - 2][j + 2] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i - 2) * 10 + (j + 2);
			over = qj[i - 2][j + 2];
			qj[i - 2][j + 2] = Constants.BLACK_ELEPHONT;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_ELEPHONT;
			qj[i - 2][j + 2] = over;
		}
		if (i <= 7 && j <= 6 && qj[i + 1][j + 1] == Constants.EMPTY
				&& (qj[i + 2][j + 2] <= Constants.RED_SOLDIER)) {
			action = i * 1000 + j * 100 + (i + 2) * 10 + (j + 2);
			over = qj[i + 2][j + 2];
			qj[i + 2][j + 2] = Constants.BLACK_ELEPHONT;
			qj[i][j] = Constants.EMPTY;
			if (ChessMap.verityMarshal(qj) && !Check.checkBlack(qj)) {
				count++;
				if (Check.checkRed(qj)) {
					step[checkFlag++] = action;
				} else {
					step[nocheck--] = action;
				}
			}
			qj[i][j] = Constants.BLACK_ELEPHONT;
			qj[i + 2][j + 2] = over;
		}
		return step;
	}

	public static int[] stepBlack(byte[][] qj) {
		int[] step = new int[115];
		int action = 0;
		byte over = 0;
		int checkFlag = 2;
		int nocheck = step.length - 1;
		for (int i = 0; i < qj.length; i++) {
			for (int j = 0; j < qj[i].length; j++) {
				byte curr = qj[i][j];
				if (curr >= 11 && curr <= 17) {
					switch (curr) {
					case Constants.BLACK_MARSHAL:
						/********************************************************/
						if (i > 7 && (qj[i - 1][j] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i - 1) * 10 + j;
							over = qj[i - 1][j];
							qj[i - 1][j] = Constants.BLACK_MARSHAL;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_MARSHAL;
							qj[i - 1][j] = over;
						}
						if (i < 9 && (qj[i + 1][j] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i + 1) * 10 + j;
							over = qj[i + 1][j];
							qj[i + 1][j] = Constants.BLACK_MARSHAL;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_MARSHAL;
							qj[i + 1][j] = over;
						}

						if (j > 3 && (qj[i][j - 1] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + i * 10 + (j - 1);
							over = qj[i][j - 1];
							qj[i][j - 1] = Constants.BLACK_MARSHAL;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_MARSHAL;
							qj[i][j - 1] = over;
						}

						if (j < 5 && (qj[i][j + 1] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + i * 10 + (j + 1);
							over = qj[i][j + 1];
							qj[i][j + 1] = Constants.BLACK_MARSHAL;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_MARSHAL;
							qj[i][j + 1] = over;
						}
						/******************************************************/
						break;
					case Constants.BLACK_GUESTS:
						/*****************************************************/
						if (i == 8 && j == 4) {
							if (qj[9][3] <= Constants.RED_SOLDIER) {
								action = 8493;
								over = qj[9][3];
								qj[i][j] = Constants.EMPTY;
								qj[9][3] = Constants.BLACK_GUESTS;
								if (ChessMap.verityMarshal(qj)
										&& !Check.checkBlack(qj)) {
									if (Check.checkRed(qj)) {
										step[0]++;
										step[checkFlag++] = action;
									} else {
										step[1]++;
										step[nocheck--] = action;
									}
								}
								qj[i][j] = Constants.BLACK_GUESTS;
								qj[9][3] = over;
							}
							if (qj[7][3] <= Constants.RED_SOLDIER) {
								action = 8473;
								over = qj[7][3];
								qj[i][j] = Constants.EMPTY;
								qj[7][3] = Constants.BLACK_GUESTS;
								if (ChessMap.verityMarshal(qj)
										&& !Check.checkBlack(qj)) {
									if (Check.checkRed(qj)) {
										step[0]++;
										step[checkFlag++] = action;
									} else {
										step[1]++;
										step[nocheck--] = action;
									}
								}
								qj[i][j] = Constants.BLACK_GUESTS;
								qj[7][3] = over;

							}
							if (qj[7][5] <= Constants.RED_SOLDIER) {
								action = 8475;
								over = qj[7][5];
								qj[i][j] = Constants.EMPTY;
								qj[7][5] = Constants.BLACK_GUESTS;
								if (ChessMap.verityMarshal(qj)
										&& !Check.checkBlack(qj)) {
									if (Check.checkRed(qj)) {
										step[0]++;
										step[checkFlag++] = action;
									} else {
										step[1]++;
										step[nocheck--] = action;
									}
								}
								qj[i][j] = Constants.BLACK_GUESTS;
								qj[7][5] = over;
							}
							if (qj[9][5] <= Constants.RED_SOLDIER) {
								action = 8495;
								over = qj[9][5];
								qj[i][j] = Constants.EMPTY;
								qj[9][5] = Constants.BLACK_GUESTS;
								if (ChessMap.verityMarshal(qj)
										&& !Check.checkBlack(qj)) {
									if (Check.checkRed(qj)) {
										step[0]++;
										step[checkFlag++] = action;
									} else {
										step[1]++;
										step[nocheck--] = action;
									}
								}
								qj[i][j] = Constants.BLACK_GUESTS;
								qj[9][5] = over;
							}
						} else if (qj[8][4] <= Constants.RED_SOLDIER) {
							action = i * 1000 + j * 100 + 84;
							over = qj[8][4];
							qj[8][4] = Constants.BLACK_GUESTS;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}

							}
							qj[i][j] = Constants.BLACK_GUESTS;
							qj[8][4] = over;
						} else {
							// do something
						}
						/*****************************************************/
						break;
					case Constants.BLACK_ELEPHONT:
						/***************************************************/
						if (i >= 7 && j >= 2
								&& qj[i - 1][j - 1] == Constants.EMPTY
								&& (qj[i - 2][j - 2] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i - 2) * 10
									+ (j - 2);
							over = qj[i - 2][j - 2];
							qj[i - 2][j - 2] = Constants.BLACK_ELEPHONT;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_ELEPHONT;
							qj[i - 2][j - 2] = over;
						}
						if (i <= 7 && j >= 2
								&& qj[i + 1][j - 1] == Constants.EMPTY
								&& (qj[i + 2][j - 2] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i + 2) * 10
									+ (j - 2);
							over = qj[i + 2][j - 2];
							qj[i + 2][j - 2] = Constants.BLACK_ELEPHONT;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_ELEPHONT;
							qj[i + 2][j - 2] = over;
						}
						if (i >= 7 && j <= 6
								&& qj[i - 1][j + 1] == Constants.EMPTY
								&& (qj[i - 2][j + 2] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i - 2) * 10
									+ (j + 2);
							over = qj[i - 2][j + 2];
							qj[i - 2][j + 2] = Constants.BLACK_ELEPHONT;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_ELEPHONT;
							qj[i - 2][j + 2] = over;
						}
						if (i <= 7 && j <= 6
								&& qj[i + 1][j + 1] == Constants.EMPTY
								&& (qj[i + 2][j + 2] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i + 2) * 10
									+ (j + 2);
							over = qj[i + 2][j + 2];
							qj[i + 2][j + 2] = Constants.BLACK_ELEPHONT;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_ELEPHONT;
							qj[i + 2][j + 2] = over;
						}
						/**************************************************/
						break;
					case Constants.BLACK_HORSE:
						/***************************************************/
						if (i >= 2 && j >= 1 && qj[i - 1][j] == Constants.EMPTY
								&& (qj[i - 2][j - 1] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i - 2) * 10
									+ (j - 1);
							over = qj[i - 2][j - 1];
							qj[i - 2][j - 1] = Constants.BLACK_HORSE;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_HORSE;
							qj[i - 2][j - 1] = over;
						}
						if (i >= 1 && j >= 2 && qj[i][j - 1] == Constants.EMPTY
								&& (qj[i - 1][j - 2] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i - 1) * 10
									+ (j - 2);
							over = qj[i - 1][j - 2];
							qj[i - 1][j - 2] = Constants.BLACK_HORSE;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_HORSE;
							qj[i - 1][j - 2] = over;
						}
						if (i <= 8 && j >= 2 && qj[i][j - 1] == Constants.EMPTY
								&& (qj[i + 1][j - 2] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i + 1) * 10
									+ (j - 2);
							over = qj[i + 1][j - 2];
							qj[i + 1][j - 2] = Constants.BLACK_HORSE;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_HORSE;
							qj[i + 1][j - 2] = over;
						}
						if (i <= 7 && j >= 1 && qj[i + 1][j] == Constants.EMPTY
								&& (qj[i + 2][j - 1] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i + 2) * 10
									+ (j - 1);
							over = qj[i + 2][j - 1];
							qj[i + 2][j - 1] = Constants.BLACK_HORSE;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_HORSE;
							qj[i + 2][j - 1] = over;
						}
						if (i >= 2 && j <= 7 && qj[i - 1][j] == Constants.EMPTY
								&& (qj[i - 2][j + 1] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i - 2) * 10
									+ (j + 1);
							over = qj[i - 2][j + 1];
							qj[i - 2][j + 1] = Constants.BLACK_HORSE;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_HORSE;
							qj[i - 2][j + 1] = over;
						}
						if (i >= 1 && j <= 6 && qj[i][j + 1] == Constants.EMPTY
								&& (qj[i - 1][j + 2] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i - 1) * 10
									+ (j + 2);
							over = qj[i - 1][j + 2];
							qj[i - 1][j + 2] = Constants.BLACK_HORSE;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_HORSE;
							qj[i - 1][j + 2] = over;
						}
						if (i <= 8 && j <= 6 && qj[i][j + 1] == Constants.EMPTY
								&& (qj[i + 1][j + 2] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i + 1) * 10
									+ (j + 2);
							over = qj[i + 1][j + 2];
							qj[i + 1][j + 2] = Constants.BLACK_HORSE;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_HORSE;
							qj[i + 1][j + 2] = over;
						}
						if (i <= 7 && j <= 7 && qj[i + 1][j] == Constants.EMPTY
								&& (qj[i + 2][j + 1] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i + 2) * 10
									+ (j + 1);
							over = qj[i + 2][j + 1];
							qj[i + 2][j + 1] = Constants.BLACK_HORSE;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_HORSE;
							qj[i + 2][j + 1] = over;
						}
						/**************************************************/
						break;
					case Constants.BLACK_CAR:
						/***************************************************/
						for (int x = i - 1; x >= 0; x--) {
							if (qj[x][j] <= Constants.RED_SOLDIER) {
								action = i * 1000 + j * 100 + x * 10 + j;
								over = qj[x][j];
								qj[x][j] = Constants.BLACK_CAR;
								qj[i][j] = Constants.EMPTY;
								if (ChessMap.verityMarshal(qj)
										&& !Check.checkBlack(qj)) {
									if (Check.checkRed(qj)) {
										step[0]++;
										step[checkFlag++] = action;
									} else {
										step[1]++;
										step[nocheck--] = action;
									}
								}
								qj[i][j] = Constants.BLACK_CAR;
								qj[x][j] = over;

							}
							if (qj[x][j] != Constants.EMPTY) {
								break;
							}
						}
						for (int x = i + 1; x <= 9; x++) {
							if (qj[x][j] <= Constants.RED_SOLDIER) {
								action = i * 1000 + j * 100 + x * 10 + j;
								over = qj[x][j];
								qj[x][j] = Constants.BLACK_CAR;
								qj[i][j] = Constants.EMPTY;
								if (ChessMap.verityMarshal(qj)
										&& !Check.checkBlack(qj)) {
									if (Check.checkRed(qj)) {
										step[0]++;
										step[checkFlag++] = action;
									} else {
										step[1]++;
										step[nocheck--] = action;
									}
								}
								qj[i][j] = Constants.BLACK_CAR;
								qj[x][j] = over;
							}
							if (qj[x][j] != Constants.EMPTY) {
								break;
							}
						}
						for (int y = j - 1; y >= 0; y--) {
							if (qj[i][y] <= Constants.RED_SOLDIER) {
								action = i * 1000 + j * 100 + i * 10 + y;
								over = qj[i][y];
								qj[i][y] = Constants.BLACK_CAR;
								qj[i][j] = Constants.EMPTY;
								if (ChessMap.verityMarshal(qj)
										&& !Check.checkBlack(qj)) {
									if (Check.checkRed(qj)) {
										step[0]++;
										step[checkFlag++] = action;
									} else {
										step[1]++;
										step[nocheck--] = action;
									}
								}
								qj[i][j] = Constants.BLACK_CAR;
								qj[i][y] = over;
							}
							if (qj[i][y] != Constants.EMPTY) {
								break;
							}
						}
						for (int y = j + 1; y <= 8; y++) {
							if (qj[i][y] <= Constants.RED_SOLDIER) {
								action = i * 1000 + j * 100 + i * 10 + y;
								over = qj[i][y];
								qj[i][y] = Constants.BLACK_CAR;
								qj[i][j] = Constants.EMPTY;
								if (ChessMap.verityMarshal(qj)
										&& !Check.checkBlack(qj)) {
									if (Check.checkRed(qj)) {
										step[0]++;
										step[checkFlag++] = action;
									} else {
										step[1]++;
										step[nocheck--] = action;
									}
								}
								qj[i][j] = Constants.BLACK_CAR;
								qj[i][y] = over;
							}
							if (qj[i][y] != Constants.EMPTY) {
								break;
							}
						}
						/**************************************************/
						break;
					case Constants.BLACK_GUN:
						/***************************************************/
						int flag = 0;
						for (int x = i - 1; x >= 0; x--) {
							if (flag == 0) {
								if (qj[x][j] == Constants.EMPTY) {
									action = i * 1000 + j * 100 + x * 10 + j;
									over = qj[x][j];
									qj[x][j] = Constants.BLACK_GUN;
									qj[i][j] = Constants.EMPTY;
									if (ChessMap.verityMarshal(qj)
											&& !Check.checkBlack(qj)) {
										if (Check.checkRed(qj)) {
											step[0]++;
											step[checkFlag++] = action;
										} else {
											step[1]++;
											step[nocheck--] = action;
										}
									}
									qj[i][j] = Constants.BLACK_GUN;
									qj[x][j] = over;
								} else {
									flag = 1;
								}
							} else {
								if (qj[x][j] != Constants.EMPTY) {
									if (qj[x][j] >= Constants.RED_CAR
											&& qj[x][j] <= Constants.RED_SOLDIER) {
										action = i * 1000 + j * 100 + x * 10
												+ j;
										over = qj[x][j];
										qj[x][j] = Constants.BLACK_GUN;
										qj[i][j] = Constants.EMPTY;
										if (ChessMap.verityMarshal(qj)
												&& !Check.checkBlack(qj)) {
											if (Check.checkRed(qj)) {
												step[0]++;
												step[checkFlag++] = action;
											} else {
												step[1]++;
												step[nocheck--] = action;
											}
										}
										qj[i][j] = Constants.BLACK_GUN;
										qj[x][j] = over;
									}
									break;
								}
							}
						}
						flag = 0;
						for (int x = i + 1; x <= 9; x++) {
							if (flag == 0) {
								if (qj[x][j] == Constants.EMPTY) {
									action = i * 1000 + j * 100 + x * 10 + j;
									over = qj[x][j];
									qj[x][j] = Constants.BLACK_GUN;
									qj[i][j] = Constants.EMPTY;
									if (ChessMap.verityMarshal(qj)
											&& !Check.checkBlack(qj)) {
										if (Check.checkRed(qj)) {
											step[0]++;
											step[checkFlag++] = action;
										} else {
											step[1]++;
											step[nocheck--] = action;
										}
									}
									qj[i][j] = Constants.BLACK_GUN;
									qj[x][j] = over;
								} else {
									flag = 1;
								}
							} else {
								if (qj[x][j] != Constants.EMPTY) {
									if (qj[x][j] >= Constants.RED_CAR
											&& qj[x][j] <= Constants.RED_SOLDIER) {
										action = i * 1000 + j * 100 + x * 10
												+ j;
										over = qj[x][j];
										qj[x][j] = Constants.BLACK_GUN;
										qj[i][j] = Constants.EMPTY;
										if (ChessMap.verityMarshal(qj)
												&& !Check.checkBlack(qj)) {
											if (Check.checkRed(qj)) {
												step[0]++;
												step[checkFlag++] = action;
											} else {
												step[1]++;
												step[nocheck--] = action;
											}
										}
										qj[i][j] = Constants.BLACK_GUN;
										qj[x][j] = over;
									}
									break;
								}
							}
						}
						flag = 0;
						for (int y = j - 1; y >= 0; y--) {
							if (flag == 0) {
								if (qj[i][y] == Constants.EMPTY) {
									action = i * 1000 + j * 100 + i * 10 + y;
									over = qj[i][y];
									qj[i][y] = Constants.BLACK_GUN;
									qj[i][j] = Constants.EMPTY;
									if (ChessMap.verityMarshal(qj)
											&& !Check.checkBlack(qj)) {
										if (Check.checkRed(qj)) {
											step[0]++;
											step[checkFlag++] = action;
										} else {
											step[1]++;
											step[nocheck--] = action;
										}
									}
									qj[i][j] = Constants.BLACK_GUN;
									qj[i][y] = over;
								} else {
									flag = 1;
								}
							} else {
								if (qj[i][y] != Constants.EMPTY) {
									if (qj[i][y] >= Constants.RED_CAR
											&& qj[i][y] <= Constants.RED_SOLDIER) {
										action = i * 1000 + j * 100 + i * 10
												+ y;
										over = qj[i][y];
										qj[i][y] = Constants.BLACK_GUN;
										qj[i][j] = Constants.EMPTY;
										if (ChessMap.verityMarshal(qj)
												&& !Check.checkBlack(qj)) {
											if (Check.checkRed(qj)) {
												step[0]++;
												step[checkFlag++] = action;
											} else {
												step[1]++;
												step[nocheck--] = action;
											}
										}
										qj[i][j] = Constants.BLACK_GUN;
										qj[i][y] = over;
									}
									break;
								}
							}
						}
						flag = 0;
						for (int y = j + 1; y <= 8; y++) {
							if (flag == 0) {
								if (qj[i][y] == Constants.EMPTY) {
									action = i * 1000 + j * 100 + i * 10 + y;
									over = qj[i][y];
									qj[i][y] = Constants.BLACK_GUN;
									qj[i][j] = Constants.EMPTY;
									if (ChessMap.verityMarshal(qj)
											&& !Check.checkBlack(qj)) {
										if (Check.checkRed(qj)) {
											step[0]++;
											step[checkFlag++] = action;
										} else {
											step[1]++;
											step[nocheck--] = action;
										}
									}
									qj[i][j] = Constants.BLACK_GUN;
									qj[i][y] = over;
								} else {
									flag = 1;
								}
							} else {
								if (qj[i][y] != Constants.EMPTY) {
									if (qj[i][y] >= Constants.RED_CAR
											&& qj[i][y] <= Constants.RED_SOLDIER) {
										action = i * 1000 + j * 100 + i * 10
												+ y;
										over = qj[i][y];
										qj[i][y] = Constants.BLACK_GUN;
										qj[i][j] = Constants.EMPTY;
										if (ChessMap.verityMarshal(qj)
												&& !Check.checkBlack(qj)) {
											if (Check.checkRed(qj)) {
												step[0]++;
												step[checkFlag++] = action;
											} else {
												step[1]++;
												step[nocheck--] = action;
											}
										}
										qj[i][j] = Constants.BLACK_GUN;
										qj[i][y] = over;
									}
									break;
								}
							}
						}
						/**************************************************/
						break;
					case Constants.BLACK_SOLDIER:
						/***************************************************/
						if (i >= 1 && (qj[i - 1][j] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + (i - 1) * 10 + j;
							over = qj[i - 1][j];
							qj[i - 1][j] = Constants.BLACK_SOLDIER;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_SOLDIER;
							qj[i - 1][j] = over;
						}
						if (i < 5 && j >= 1
								&& (qj[i][j - 1] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + i * 10 + (j - 1);
							over = qj[i][j - 1];
							qj[i][j - 1] = Constants.BLACK_SOLDIER;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_SOLDIER;
							qj[i][j - 1] = over;
						}
						if (i < 5 && j <= 7
								&& (qj[i][j + 1] <= Constants.RED_SOLDIER)) {
							action = i * 1000 + j * 100 + i * 10 + (j + 1);
							over = qj[i][j + 1];
							qj[i][j + 1] = Constants.BLACK_SOLDIER;
							qj[i][j] = Constants.EMPTY;
							if (ChessMap.verityMarshal(qj)
									&& !Check.checkBlack(qj)) {
								if (Check.checkRed(qj)) {
									step[0]++;
									step[checkFlag++] = action;
								} else {
									step[1]++;
									step[nocheck--] = action;
								}
							}
							qj[i][j] = Constants.BLACK_SOLDIER;
							qj[i][j + 1] = over;
						}
						/**************************************************/
						break;
					}
				}
			}
		}
		return step;
	}

	public static void main(String[] args) {
		byte[][] qj = {
		// 0 1 2 3 4 5 6 7 8
				{ 00, 00, 00, 00, 05, 04, 03, 00, 00 }, // 0
				{ 00, 00, 00, 00, 04, 00, 00, 00, 00 }, // 1
				{ 00, 00, 00, 00, 03, 00, 00, 00, 00 }, // 2
				{ 00, 00, 00, 11, 16, 00, 00, 00, 00 }, // 3
				{ 00, 00, 00, 00, 00, 00, 00, 00, 00 }, // 4
				{ 00, 00, 00, 00, 00, 00, 00, 00, 00 }, // 5
				{ 00, 00, 00, 00, 00, 00, 00, 00, 00 }, // 6
				{ 00, 00, 00, 00, 13, 14, 00, 00, 00 }, // 7
				{ 00, 00, 01, 00, 00, 00, 01, 00, 00 }, // 8
				{ 00, 00, 13, 15, 00, 14, 00, 00, 00 } // 9
		};
		Test.display(qj);

		int[] actions = stepBlack(qj);
		System.out.println(actions[0]);
		for (int i = 2; i <= actions[0] + 1; i++) {
			System.out.print(actions[i] + " , ");
		}
		System.out.println("\n" + actions[1]);
		for (int i = 114; i > 114 - actions[1]; i--) {
			System.out.print(actions[i] + " , ");
		}
	}
}